<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Gen city_js file
 *
 * Usage: php index.php city_js gen > target_path
 */

/*
 * $Id: city_js.php 124 2011-09-13 14:32:07Z leikou@163.com $
 */


class City_js extends CI_Controller
{
    private $_provinces = array();
    private $_citys = array();
    private $_areas = array();


    public function gen()
    {
        // Get data from database
        $query = $this->db->from('province')->get();
        $this->_provinces = $query->result_array();

        $query = $this->db->from('city')->get();
        $this->_citys = $query->result_array();

        $query = $this->db->from('area')->get();
        $this->_areas = $query->result_array();

        // Render template
        $city_js = $this->load->smarty('city_js.tpl', array(
            'provinces' => $this->_provinces,
            'citys' => $this->_citys,
            'areas' => $this->_areas,
        ), TRUE);
        
        echo $city_js;
        exit;
    }
}


/* End of file: city_js.php */
/* Location ./tools/controllers/city_js.php */
